package com.gy.api.pc.user.controller;

import cn.dev33.satoken.annotation.SaCheckLogin;
import cn.dev33.satoken.stp.StpUtil;
import com.github.pagehelper.PageInfo;
import com.gy.api.base.*;
import com.gy.api.mobile.company.domain.vo.UpdateCompanyPasswordVO;
import com.gy.api.mobile.company.service.ICompanyService;
import com.gy.api.mobile.user.service.IUserService;
import com.gy.api.pc.sys.authority.domain.vo.SysAuthoritySearchVO;
import com.gy.api.pc.sys.authority.domain.vo.SysAuthorityTreeVO;
import com.gy.api.pc.sys.authority.domain.vo.SysAuthorityVO;
import com.gy.api.pc.sys.authority.service.ISysAuthorityService;
import com.gy.api.pc.sys.role.domain.vo.SysRoleVO;
import com.gy.api.pc.sys.role.service.ISysRoleService;
import com.gy.api.pc.sys.user.domain.vo.*;
import com.gy.api.pc.sys.user.service.ISysUserService;
import com.gy.api.pc.user.domain.vo.CompanyUserSearchVO;
import com.gy.api.pc.user.domain.vo.CompanyUserVO;
import com.gy.api.pc.user.domain.vo.MobileUserSearchVO;
import com.gy.api.pc.user.domain.vo.MobileUserVO;
import com.gy.util.BindingResultUtil;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import io.swagger.annotations.ApiParam;
import org.apache.commons.lang3.StringUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.validation.BindingResult;
import org.springframework.web.bind.annotation.*;

import javax.validation.Valid;
import java.util.List;


@Api( tags = ApiIndex.UserController)
@RequestMapping(value = "/user")
@RestController
public class UserController {

    @Autowired
    private IUserService userService;

    @ApiOperation(value = "查询前端用户列表")
    @GetMapping(value = "/user_list")
    @SaCheckLogin
    public R<RestPage<List<MobileUserVO>>> user_list(
            @ApiParam(value = "查询参数") @ModelAttribute MobileUserSearchVO searchVO) {
        List<MobileUserVO> list = userService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }


    @Autowired
    private ICompanyService companyService;

    @ApiOperation(value = "查询企业用户列表")
    @GetMapping(value = "/company_list")
    @SaCheckLogin
    public R<RestPage<List<CompanyUserVO>>> company_list(
            @ApiParam(value = "查询参数") @ModelAttribute CompanyUserSearchVO searchVO) {
        List<CompanyUserVO> list = companyService.getList(searchVO);
        RestPage restPage = new RestPage( new PageInfo(list),list);
        return new R(restPage);
    }


}
